#include <iostream>
#define N 100

using namespace std;

int not_in_array(int reunion[], int size, int number){
int i,el=size, nr=number;
for(i=0;i<el;i++)
    if(reunion[i]==nr)
        return i;
return 0;
}
int arr_union(int array_a[], int array_b[], int reunion[], int elements_a, int elements_b){
int i, size;
for(i=0;i<elements_a;i++)
    reunion[i]=array_a[i];
	size=elements_a;
for(i=0;i<elements_b;i++)
    if(not_in_array(reunion, size, array_b[i])<0){
        reunion[size]=array_b[i];
        ++size;}
return size;
}


void readintVector_A(int array_a[], int elements_a){
for (int i=0; i<elements_a; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_a[i];
	cout<<"\n";}
}

void readintVector_B(int array_b[], int elements_b){
for (int i=0; i<elements_b; i++){
	cout<<"a["<<i<<"]=";
	cin>>array_b[i];
	cout<<"\n";}
}

void printVector(int reunion[], int re){
for(int i=0; i<re; i++){
	cout<<reunion[i]<<" ";}
	cout<<"\n";
}

int main(){
int array_a[N];
int array_b[N];
int reunion[N];
int elements_a;
int elements_b;
int re;

cout<<"Type the number of elements you want in the array A: ";
cin>>elements_a;
readintVector_A(array_a, elements_a);

cout<<"Type the number of elements you want in array B: ";
cin>> elements_b;
readintVector_B(array_b, elements_b);

cout<<"The original array A is ";
for(int i=0; i<elements_a; i++){
	cout<<array_a[i]<<" ";}
cout<<endl;

cout<<"The original array B is ";
for(int i=0; i<elements_b; i++){
	cout<<array_b[i]<<" ";}
cout<<endl;

re=arr_union( array_a, array_b, reunion, elements_a,  elements_b);
cout<<"The reunion between A and B is: "<<endl;
printVector(reunion, re);


return 0;
}
